# coding=utf-8
"""
Author: Mr.夏末
@Function: 接口测试示例
"""
import json

import requests

#构造参数
p_dict = {
    'page': '1',
    'keyword': '美',
    'rows': '3'
}
#发包
res = requests.post('https://route.showapi.com/1196-1?showapi_appid=968768&showapi_sign=bf5cde24776d432992fdf3a741b0c738',data=p_dict)
#查看文本结果
print(res.text)

res = res.text
res = json.loads(res)['showapi_res_body']['data']
print(res)

#断言
if str(len(res)) == p_dict.get('rows'):
    flg = True
    for i in res:
        if not i.get('title').__contains__(p_dict.get('keyword')):
            print("FAIL")
            flg = False
            break
    if flg:
        print("PASS")
else:
    print("FAIL")
